import os
import glob

class dirManager:
    def __init__(self, mainDir):
        self.dirs = {}
        self.dirs['main'] = os.environ['HOME'] + mainDir
        self.dirs['data'] = self.dirs['main']  + '/data'
        self.dirs['datasets']  = self.dirs['main'] + '/datasets'
        self.dirs['exp']  = self.dirs['main'] + '/experiments'
        self.dirs['report']  = self.dirs['main'] + '/reports'
        self.setup()
    
    #creating nessacery directories
    def setup(self):
        for d in self.dirs.items():
            if(not os.path.isdir(d[1])):
                os.makedirs(d[1], 0777)
                print "    Directory " + d[1] + " setup"
    
    def getDatasetList(self):
        return glob.glob(self.dirs['datasets'] + "/*.dataset")
    
    def getDatasetMatch(self,express):
        return glob.glob(self.dirs['datasets'] + "/" + express)